#!/bin/bash

ARG_COUNT=$#  # 获取传入参数的个数

cd build
rm -rf ./*
# 检查第一个参数是否为 "test"
if [ "$1" == "test" ]; then
    # 如果是 "test"，则启用测试构建，禁用源代码构建
    cmake .. -DBUILD_TESTS=ON -DBUILD_SRC=OFF -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake
elif [ "$1" == "src" ]; then
    # 如果是 "src"，则启用源代码构建，禁用测试构建
    cmake .. -DBUILD_TESTS=OFF -DBUILD_SRC=ON -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake
else
    echo "Usage: $0 {test|src}"
    exit 1
fi

if [ $? -ne 0 ]; then 
    echo "cmake fail"
    exit 1
fi

make
